package org.dromara.common.translation.core.impl

import org.dromara.common.core.service.DictService
import org.dromara.common.core.utils.StringUtils
import org.dromara.common.translation.annotation.TranslationType
import org.dromara.common.translation.constant.TransConstant
import org.dromara.common.translation.core.TranslationInterface

/**
 * 字典翻译实现
 *
 * @author LikeYouDo
 * @date 2025/07/26
 */
@TranslationType(type = TransConstant.DICT_TYPE_TO_LABEL)
class DictTypeTranslationImpl(
    private val dictService: DictService
) : TranslationInterface<String> {
    override fun translation(key: Any, other: String?): String? {
        if (key is String && StringUtils.isNotBlank(other)) {
            return dictService.getDictLabel(other, key)
        }
        return null
    }
}
